import {defineComponent} from "vue"
import {usePreviewImages} from "@/components/FunctionComponents";

export default defineComponent({
    props: {
        data: {
            type: Array<any>,
            required: true
        },
        active: {
            type: Array<number | string>,
            required: true
        }
    },
    emits: {
        rename: (res: any) => true,
        active: (res: any) => true
    },
    setup(props, {emit}) {
        /**
         * 编辑文件名
         * @constructor
         */
        function EditFileName(res: any) {
            emit('rename', res)
        }


        /**
         * 预览文件
         * @constructor
         */
        function PreviewFile(res: any) {
            usePreviewImages(res.url)
        }

        /**
         * 选中资源
         */
        function choiceRes(res: any) {
            emit('active', res)
        }


        /**
         * 选中资源
         */
        function choiceResList(res: any[]) {
            console.log(res);
            res.forEach(item => choiceRes(item))
        }
        return {
            EditFileName, PreviewFile, choiceRes,choiceResList
        }
    }
})